/**
  * @FileName: VerifyPhoneNumberRequest.java
  * @Package:com.bdtop.dbl.server.apis
  * @Description: TODO
  * @author: MingjunLi
  * @date:2014-9-25
  * @version V1.0
  */
package com.bdtop.dbl.server.request;

import com.bdtop.dbl.server.response.BaseResponse;
import com.bdtop.dbl.thirdparty.asynchttp.HttpPostRequest;
import com.bdtop.dbl.thirdparty.asynchttp.RequestCallback;
import com.bdtop.dbl.utils.Constants;
import com.bdtop.dbl.utils.DBLDebug;
import com.google.gson.Gson;

import java.io.Serializable;

/**
 * @ClassName: VerifyPhoneNumberRequest
 * @Description: TODO
 * @author: MingjunLi
 * @date:2014-9-25
 */
public class VerifyPhoneNumberRequest extends HttpPostRequest {

    /**
      * @param callback
      */
    public VerifyPhoneNumberRequest(RequestCallback callback) {
        super(callback);
        getRequestParams().add(Constants.COMMAND, Constants.CMD_VERIFY);
    }
    
    public void setParams(VerifyParams params) {
        getRequestParams().add(Constants.PARAM_USER_NAME, params.getPhoneNumber());
        getRequestParams().add(Constants.PARAM_VERIFY_CODE, params.getVerifyCode());
        getRequestParams().add(Constants.PARAM_IMEI, params.getImei());
        getRequestParams().add(Constants.PARAM_IMSI, params.getImsi());
        getRequestParams().add(Constants.PARAM_PWD, params.getPassword());
    }

    @Override
    protected String getUrl() {
        return Constants.SERVER_ADDRESS;
    }

    @Override
    protected Object parse(String responseString) {
        DBLDebug.logd("VerifyPhoneNumberRequest response:" + responseString);
        
        Gson gson = new Gson();
        BaseResponse baseResponse = gson.fromJson(responseString, BaseResponse.class);
        return baseResponse;
    }

    public static class VerifyParams implements Serializable {

        /**
          * @Fields: serialVersionUID
          * @Todo: TODO
          */
        private static final long serialVersionUID = 8001327527700986716L;
        
        private String phoneNumber;
        private String password;
        private String verifyCode;
        private String imei;
        private String imsi;
        
        /**
         * @return phoneNumber
         */
        public String getPhoneNumber() {
            return phoneNumber;
        }
        /**
         * @param phoneNumber the phoneNumber to set
         */
        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }
        /**
         * @return password
         */
        public String getPassword() {
            return password;
        }
        /**
         * @param password the password to set
         */
        public void setPassword(String password) {
            this.password = password;
        }
        /**
         * @return verifyCode
         */
        public String getVerifyCode() {
            return verifyCode;
        }
        /**
         * @param verifyCode the verifyCode to set
         */
        public void setVerifyCode(String verifyCode) {
            this.verifyCode = verifyCode;
        }
        /**
         * @return imei
         */
        public String getImei() {
            return imei;
        }
        /**
         * @param imei the imei to set
         */
        public void setImei(String imei) {
            this.imei = imei;
        }
        /**
         * @return imsi
         */
        public String getImsi() {
            return imsi;
        }
        /**
         * @param imsi the imsi to set
         */
        public void setImsi(String imsi) {
            this.imsi = imsi;
        }
    }
}
